<!DOCTYPE HTML>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="gray-bg">
    
     <div class="container-div">
		<div class="row">
			<div class="col-sm-12 search-collapse">
				<form id="formId">
					<div class="select-list">
						<ul>
							<li>
								交易姓名：<input type="text" id="name" name="name"/>
							</li>
							<li>
								用户编号：<input type="text" name="merchantId"/>
							</li>

							<li>
								代理商编号：<input type="text" name="agentId"/>
							</li>
							<li>
								ID：<input type="text" name="id"/>
							</li>
							<li class="select-time">
								<label>交易时间： </label>
								<input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginTime]"/>
								<span>-</span>
								<input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endTime]"/>
							</li>
							<li>
							  交易类型：<select name="type" >
									<option value="">所有</option>
									<option value="0">加码</option>
									<option value="1">扣码</option>
								</select>
							</li>
							<li>
								<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
								<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
							</li>
							
							<li>
								&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
								<a class="btn btn-primary btn-rounded btn-sm" id="addCode">代理商加码</a>
							</li>
						</ul>
					</div>
				</form>
			</div>
			<div class="col-sm-12 select-table table-striped">
				<font><b>码交易数量：</b><span id="spanSumCount"> 0</span>个</font>
				<table id="bootstrap-table" data-mobile-responsive="true"></table>
			</div>
		</div>
	</div>
    <div th:include="include :: footer"></div>
    <script th:inline="javascript">
        var detailFlag = [[${@permission.hasPermi('system:codeRecord:detail')}]];
        var removeFlag = [[${@permission.hasPermi('system:codeRecord:remove')}]];
        var prefix = ctx + "system/codeRecord";
        $(function() {
        	$("#spanSumCount").text(0);
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
            	detailUrl: prefix + "/detail/{id}",
				exportUrl: prefix + "/export",
                modalName: "升级码交易记录",
				search: false,
		        showExport: false,
                columns: [{
		            checkbox: true
		        },
				{
					field : 'id', 
					title : '主键',
					visible: false
				},
				{
					field : 'name', 
					title : '名称',
					sortable: true
				},
				{
					field : 'count', 
					title : '数量',
					sortable: true
				},
				{
					field : 'price', 
					title : '单价',
					sortable: true
				},
				{
					field : 'fromId', 
					title : '来源id',
					sortable: true
				},
				{
					field : 'toId', 
					title : '去向id',
					sortable: true
				},
				{
					field : 'field1', 
					title : '操作前余量',
					sortable: true
				},
				{
					field : 'field2', 
					title : '操作后余量',
					sortable: true
				},
				{
					field : 'type', 
					title : '交易类型',
					 formatter: function(value, row, index) {
							 if(row.sumCount != null ){
								 $("#spanSumCount").text(row.sumCount);
							 }
			            	if(value=="0"){
			            		return "加码";
			            	} else {
			            		return "扣码";
			            	}
			            }
				},
				{
					field : 'createTime', 
					title : '交易时间',
					sortable: true
				},
				{
					field : 'merchantId', 
					title : '用户类型',
					 formatter: function(value, row, index) {
			            	if(value==null){
			            		return "代理商";
			            	} else {
			            		return "用户";
			            	}
			            }
				},
				{
		            title: '操作',
		            align: 'center',
		            formatter: function(value, row, index) {
		            	var actions = [];															
		            	actions.push('<a class="btn btn-warning btn-xs ' + detailFlag + '" href="#" onclick="$.operate.detail(\'' + row.id + '\')">详细</a> ');
		            	return actions.join('');
		            }
		        }
		       ]
            };
            $.table.init(options);
            
        	/**
			 * 跳转加码页面
			 */
			$("#addCode").bind("click", function() {
				$.operate.add();
			});
        });
    </script>
</body>
</html>